﻿using System;

namespace DanielVaughan.Services
{
	/// <summary>
	/// <see cref="EventArgs"/> for 
	/// the <seealso cref="ISettingsService.SettingChanging"/> event.
	/// </summary>
	public class SettingChangingEventArgs : SettingChangeEventArgs
	{
		bool cancel;

		/// <summary>
		/// Gets or sets a value indicating whether 
		/// this <see cref="SettingChangingEventArgs"/> has been canceled.
		/// Can only be set to <c>true</c>.
		/// </summary>
		/// <value><c>true</c> if this instance's Cancel property was set to <c>true</c>; 
		/// otherwise, <c>false</c>.</value>
		public bool Cancel
		{
			get
			{
				return cancel;
			}
			set
			{
				/* Cancelled can only be set to true. */
				if (!value)
				{
					return;
				}
				cancel = true;
			}
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="SettingChangingEventArgs"/> class.
		/// </summary>
		/// <param name="settingName">Name of the setting.</param>
		/// <param name="settingValue">The setting value.</param>
		public SettingChangingEventArgs(string settingName, object settingValue)
			: base(settingName, settingValue)
		{
		}
	}
}